package com.prs.crm.domain.oa;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.prs.crm.domain.FlowEntity;
import com.prs.crm.domain.doc.Document;
import com.prs.crm.domain.hr.Person;

@Entity
@Table(name="oa_apply")
public class Apply extends FlowEntity{
	
	private static final long serialVersionUID = 1L;
	
	@Id@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer id;
	private String title;
	@Lob
	private String content;
	private String attach;
	private String level;
	private String state;
	@ManyToMany(fetch=FetchType.LAZY)
	private Set<Person> copyToPersons;
	@OneToMany(fetch=FetchType.LAZY,mappedBy="apply")
	private Set<ApplyCritique> critiques;
	@OneToMany(fetch=FetchType.LAZY,mappedBy="apply")
	private Set<Document> docs;
	
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getAttach() {
		return attach;
	}
	public void setAttach(String attach) {
		this.attach = attach;
	}
	public String getLevel() {
		return level;
	}
	public void setLevel(String level) {
		this.level = level;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}

	public void setCopyToPersons(Set<Person> copyToPersons) {
		this.copyToPersons = copyToPersons;
	}
	public Set<Person> getCopyToPersons() {
		return copyToPersons;
	}
	public void setCritiques(Set<ApplyCritique> critiques) {
		this.critiques = critiques;
	}
	public Set<ApplyCritique> getCritiques() {
		return critiques;
	}
	
	public void addCopyToPersons(Collection<Person> persons) {
		if(copyToPersons == null) {
			copyToPersons = new HashSet<Person>();
		}
		if(persons != null) {
			copyToPersons.addAll(persons);	
		}
	}
	public Set<Document> getDocs() {
		return docs;
	}
	public void setDocs(Set<Document> docs) {
		this.docs = docs;
	}
	
}
